//
//	_MiscMergeQuery.m -- GUI controller for obtaining user feedback
//		Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
//				Version 1.0.  All rights reserved.
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	


#import "_MiscMergeQuery.h"

@implementation _MiscMergeQuery

static id _sharedInstance = nil;

+ new
{
	if (!_sharedInstance) {
		_sharedInstance = [super alloc];
	}
	return [_sharedInstance init];
}

+ alloc
{
	[self error:"Don't call +alloc for Query objects!"];
	return nil;
}

- init
{
	static BOOL initted = NO;

	if (!initted) {
		self = [super init];
		initted = YES;
	}
	[self loadNibIfNeeded];
	[self setButtonTitles:[self getLocalStringFor:"OK"]
			and:[self getLocalStringFor:"Continue"]];
	[self setTitle:[self getLocalStringFor:"Merge"]];
	status = MISC_QueryNone;
	return self;
}

- showWindow:sender
{
	[super showWindow:sender];
	status = MISC_QueryInProgress;
	[window makeKeyAndOrderFront:self];
	[window makeFirstResponder:dataField];
	[dataField selectText:self];
	[NXApp runModalFor:window];
	return self;
}

- acceptQuery:sender		// accept...or not...
{

	[window orderOut:self];
	[NXApp stopModal];
	status = MISC_QueryAccepted;
	return self;
}

- cancelQuery:sender		// cancel modal loop...
{
	[window orderOut:self];
	[NXApp stopModal];
	status = MISC_QueryCancelled;
	return self;
}

- setQuestion:(const char *)aString
{
	[questionField setStringValue:aString];
	status = MISC_QueryNone;
	return self;
}

- setTitle:(const char *)aString
{
	[titleField setStringValue:aString];
	return self;
}

- setButtonTitles:(const char *)aString and:(const char *)bString
{
	[button1 setTitle:aString];
	[button2 setTitle:bString];
	return self;
}

- (const char *)stringValue
{
	return [dataField stringValue];
}

- (MiscMergeQueryStatus)status { return status; }

- (const char *)getLocalStringFor:(const char *)aString
{
	// ***** we should use the MiscBundle or something to allow
	// these strings to be localized.  Right now they pass through
	// untouched...
	return aString;
}

@end
